<script setup>

import {openFolderDialog} from "@/util/file";

const path = defineModel();

// 选择文件夹函数
async function selectFolder() {
  try {
    // 调用 Electron 对话框 API
    const result = await openFolderDialog();

    if (!result.canceled && result.filePaths.length > 0) {
      path.value = result.filePaths[0]
    }
  } catch (error) {
    console.error("选择文件夹失败:", error);
  }
}
</script>

<template>
  <div class="box-select-folder">
    <el-input placeholder="请输入项目目录" disabled v-model="path"></el-input>
    <el-button @click="selectFolder">选择</el-button>
  </div>
</template>

<style scoped lang="scss">
.box-select-folder {

  .el-input {
    width: 300px;
    margin-right: 10px;
  }

}
</style>